package com.htfyun.ft.common;

import android.content.Context;
import android.provider.Settings;

import com.htfyun.ft.FTApplication;

public class SettingsUtils {

    /*
     * 20170418,copy from frameworks to make eclipse compile OK.don't changed!!
     *  Settings.System.POINTER_LOCATION
     */
    private static final String POINTER_LOCATION = "pointer_location";
    /**
     * Settings.System.SHOW_TOUCHES
     */
    private static final String SHOW_TOUCHES = "show_touches";

    private final static int FT_TIME_SCREEN_OFF = 60 * 1000 * 15; //15 min

    public static void setScreenOffTimeForFT(Context context) {
        setScreenOffTime(context, FT_TIME_SCREEN_OFF);
    }

    public static void setScreenOffTime(Context context, int time_ms) {
        try {
            Settings.System.putInt(context.getContentResolver(),
                    "screen_off_timeout", time_ms);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /*
     * 20170418,this needs SystemUI privilige.
     *
     */
    public static void setTouchShowEnabled(boolean enabled) {

        Settings.System.putInt(FTApplication.getContext().getContentResolver(),
                POINTER_LOCATION, enabled ? 1 : 0);
        Settings.System.putInt(FTApplication.getContext().getContentResolver(),
                SHOW_TOUCHES, enabled ? 1 : 0);

    }

}
